package game.engine;
import java.io.Serializable;

import physics.Body;
import physics.joints.Joint;
import tools.Point;
/**
 * This controls how a GraphicsObject is synced to the world. if type == BODY its position and rotation will be set according to the body with the specified id. if type == JOINT its position and rotation will be set according to the joint with the specified id. if type == DYNAMIC its position and rotation will be set by the GameObject that contains the GraphicsObject
 * 
 * @author toni
 * 
 */
public class GSync implements Serializable {
	public enum SyncType {
		BODY, JOINT, DYNAMIC
	}
	public SyncType type;
	public int grOid, targetId;
	public Point offset;
	public float angleoffset;
	public GSync(SyncType type, int grOid, int targetId) {
		super();
		this.type = type;
		this.grOid = grOid;
		this.targetId = targetId;
		this.offset = new Point();
	}
	public GSync(Body b) {
		this(b, new Point(), 0);
	}
	public GSync(Body b, Point offset, float angle) {
		type = SyncType.BODY;
		targetId = b.id;
		this.offset = offset;
		this.angleoffset = angle;
	}
	public GSync(Joint j) {
		type = SyncType.JOINT;
		targetId = j.id;
		this.offset = new Point();
	}
	public GSync() {
		type = SyncType.DYNAMIC;
		targetId = -1;
		this.offset = new Point();
	}
	public GSync(SyncType type, int grOid, int targetId, Point offset, float angleoffset) {
		super();
		this.type = type;
		this.grOid = grOid;
		this.targetId = targetId;
		this.offset = offset;
		this.angleoffset = angleoffset;
	}
}
